package td.pt.event;

import td.pt.widget.TagTreePopupPresenter.TagNavigationType;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;

public class UseTagNavigationEvent extends
		GwtEvent<UseTagNavigationEvent.UseTagNavigationHandler> {

	public static Type<UseTagNavigationHandler> TYPE = new Type<UseTagNavigationHandler>();
	private TagNavigationType navigationType;
	private HasHandlers source;

	public interface UseTagNavigationHandler extends EventHandler {
		void onUseTagNavigation(UseTagNavigationEvent event);
	}

	public interface UseTagNavigationHasHandlers extends HasHandlers {
		HandlerRegistration addUseTagNavigationHandler(
				UseTagNavigationHandler handler);
	}

	public UseTagNavigationEvent(TagNavigationType navigationType,
			HasHandlers source) {
		this.navigationType = navigationType;
		this.source = source;
	}

	public TagNavigationType getNavigationType() {
		return navigationType;
	}

	public HasHandlers getSource() {
		return source;
	}

	@Override
	protected void dispatch(UseTagNavigationHandler handler) {
		handler.onUseTagNavigation(this);
	}

	@Override
	public Type<UseTagNavigationHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<UseTagNavigationHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, TagNavigationType navigationType) {
		source.fireEvent(new UseTagNavigationEvent(navigationType, source));
	}
}
